/**
 * This class is used to parse the operation arguments from the request
 */
package com.comp6231.replica1;

/**
 * @author Farzana Alam
 * 
 */
public class RequestParser {

	private String badgeID = "";
	private String firstName = "";
	private String lastName = "";
	private String description = "";
	private String status;
	private String lastDate = "";
	private String lastLocation = "";
	private String address = "";
	private String recordID = "";
	private String remoteStationServerName = "";

	public RequestParser(String operationName, String arguments) {
		pareseArguments(operationName, arguments);
	}

	private void pareseArguments(String operationName, String arguments) {
		switch (operationName.trim().toUpperCase()) {
		case "CREATEMRECORD":
			parseCreateMR(arguments);
			break;
		case "CREATECRECORD":
			parseCreateCR(arguments);
			break;
		case "GETRECORDCOUNTS":
			badgeID = arguments;
			break;
		case "EDITRECORD":
			parseEdit(arguments);
			break;
		case "TRANSFERRECORD":
			parseTransfer(arguments);
			break;
		}
	}

	// Log transferReecord(in string badgeID, in string recordID, in string
	// remoteStationServerName);
	private void parseTransfer(String arguments) {
		String[] args = arguments.split(" ## ");
		setBadgeID(args[0]);
		setRecordID(args[1]);
		setRemoteStationServerName(args[2]);
	}

	// Log editRecord(in string badgeID, in string lastName, in string recordID,
	// in IndividualsStatus
	// newStatus);
	private void parseEdit(String arguments) {
		String[] args = arguments.split(" ## ");
		setBadgeID(args[0]);
		setLastName(args[1]);
		setRecordID(args[2]);
		setStatus(args[3]);
	}

	// Log createCRecord(in string badgeID, in string firstName, in string
	// lastName, in string description,in IndividualsStatus status);
	private void parseCreateCR(String arguments) {
		String[] args = arguments.split(" ## ");
		setBadgeID(args[0]);
		setFirstName(args[1]);
		setLastName(args[2]);
		setDescription(args[3]);
		setStatus(args[4]);

	}

	// Log createMRecord(in string badgeID, in string firstName, in string
	// lastName, in string address,
	// in string lastDate, in string lastLocation, in IndividualsStatus status);
	private void parseCreateMR(String arguments) {
		String[] args = arguments.split(" ## ");
		setBadgeID(args[0]);
		setFirstName(args[1]);
		setLastName(args[2]);
		setAddress(args[3]);
		setLastDate(args[4]);
		setLastLocation(args[5]);
		setStatus(args[6]);

	}

	public String getBadgeID() {
		return badgeID;
	}

	public String getFirstName() {
		return firstName;
	}

	public String getLastName() {
		return lastName;
	}

	public String getDescription() {
		return description;
	}

	public String getStatus() {
		return status;
	}

	public String getLastDate() {
		return lastDate;
	}

	public String getLastLocation() {
		return lastLocation;
	}

	public String getAddress() {
		return address;
	}

	public String getRecordID() {
		return recordID;
	}

	public String getRemoteStationServerName() {
		return remoteStationServerName;
	}

	private void setBadgeID(String badgeID) {
		this.badgeID = badgeID.trim();
	}

	private void setFirstName(String firstName) {
		this.firstName = firstName.trim();
	}

	private void setLastName(String lastName) {
		this.lastName = lastName.trim();
	}

	private void setDescription(String description) {
		this.description = description.trim();
	}

	private void setStatus(String status) {
		this.status = status;
	}

	private void setLastDate(String lastDate) {
		this.lastDate = lastDate.trim();
	}

	private void setLastLocation(String lastLocation) {
		this.lastLocation = lastLocation.trim();
	}

	private void setAddress(String address) {
		this.address = address.trim();
	}

	private void setRecordID(String recordID) {
		this.recordID = recordID.trim();
	}

	private void setRemoteStationServerName(String remoteStationServerName) {
		this.remoteStationServerName = remoteStationServerName.trim();
	}

}
